package org.example.cake.service.impl;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import org.example.cake.mapper.OrdercakeMapper;
import org.example.cake.entity.Ordercake;
import org.example.cake.service.OrdercakeService;

import java.util.List;

@Service
public class OrdercakeServiceImpl implements OrdercakeService {

    @Resource
    private OrdercakeMapper ordercakeMapper;

    @Override
    public int deleteByPrimaryKey(Integer orderid) {
        return ordercakeMapper.deleteByPrimaryKey(orderid);
    }

    @Override
    public int insert(Ordercake record) {
        return ordercakeMapper.insert(record);
    }

    @Override
    public int insertSelective(Ordercake record) {
        return ordercakeMapper.insertSelective(record);
    }

    @Override
    public Ordercake selectByPrimaryKey(Integer orderid) {
        return ordercakeMapper.selectByPrimaryKey(orderid);
    }

    @Override
    public int updateByPrimaryKeySelective(Ordercake record) {
        return ordercakeMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Ordercake record) {
        return ordercakeMapper.updateByPrimaryKey(record);
    }

    /**
     * 根据用户id查询不同订单状态的订单信息
     *
     * @param userid 用户id
     * @return 集合
     */
    public List<Ordercake> selectOrdercake(Integer userid) {
        return ordercakeMapper.selectOrdercake(userid);
    }

    /**
     * 点击申请退款就修改退款的类型从0[未退款]改为1[退款中]
     *
     * @param orderid 订单id
     * @return 收影响的行数
     */
    public int applyrefund(@Param("orderid") Integer orderid,@Param("userreason") String userreason){
        return ordercakeMapper.applyrefund(orderid,userreason);
    }

    /**
     * 根据用户id查询他申请提交的订单
     *
     * @param userid 用户id
     * @return 订单集合
     */
    public List<Ordercake> selectapplyfund(Integer userid,
                                           String cakeName,
                                           String orderstatus,
                                           String ordernum) {
        return ordercakeMapper.selectapplyfund(userid,cakeName,orderstatus,ordernum);
    }

    @Override
    public int updateRefundsStatus(Integer orderid, Integer refund) {
        return ordercakeMapper.updateRefundsStatus(orderid,refund);
    }
    /**
     * 新增订单
     * @Date 2025-08-04 谭丽那
     * @param ordercake
     * @return
     */
    @Override
    public Integer addcakeorder(Ordercake ordercake) {
        return ordercakeMapper.addcakeorder(ordercake);
    }
    /**
     * 修改订单总数
     * @param count
     * @param payid
     * @return
     */
    @Override
    public Integer updateordercount(Integer count, int payid) {
        return ordercakeMapper.updateordercount(count,payid);
    }
    /**
     * 获取今日订单总数
     * @return
     */
    @Override
    public Integer getTodayOrderCount() {
        return ordercakeMapper.getTodayOrderCount();
    }
    /**
     * 获取今日订单
     * @param lastSevenDay 日期
     * @return
     */
    @Override
    public Integer getTodayOrderCount(String lastSevenDay) {
        return ordercakeMapper.getCount(lastSevenDay);
    }

    /**
     * 获取这个月的总数
     * @return
     */
    @Override
    public Integer getMonthOrderCount() {
        return ordercakeMapper.getMonthOrderCount();
    }

    @Override
    public String gettodayMoney() {
        return ordercakeMapper.gettodayMoney();
    }

    @Override
    public String getmonthMoney() {
        return ordercakeMapper.getmonthMoney();
    }
    /**
     * 根据用户id查询他申请提交的订单小程序端
     * @param userid 用户id
     * @return 订单集合
     */
    public List<Ordercake> selectapplyfundFront(@Param("userid") Integer userid){
        return ordercakeMapper.selectapplyfundFront(userid);
    }
    /**
     * 商家不同意退款方法
     * @param shopreply 商家回复
     * @param orderid 订单id
     * @return 受影响的行数
     */
    public Integer refundReply(@Param("shopreply")  String shopreply,@Param("orderid") Integer orderid){
        return ordercakeMapper.refundReply(shopreply,orderid);
    }

    /**
     * 查询今日的订单
     * @return 订单集合
     */
    public List<Ordercake> selectTodayOrder(){
        return ordercakeMapper.selectTodayOrder();
    }
    /**
     * 用户确认收货
     * @param orderid  订单id
     * @return 受影响的行数
     */
    public int confirmGoods(@Param("orderid") Integer orderid){
        return ordercakeMapper.confirmGoods(orderid);
    }
    /**
     * 用户删除订单
     * @param orderid 订单id
     * @return 受影响的行数
     */
    public int deleteGoods(@Param("orderid") Integer orderid){
        return ordercakeMapper.deleteGoods(orderid);
    }
    /**
     * 接单
     * @param orderid 订单id
     * @return 受影响的行数
     */
    public int updateGoods(@Param("orderid") Integer orderid){
        return ordercakeMapper.updateGoods(orderid);
    }
}
